/*
  This file is part of 'Trivial chess'.

  'Trivial chess' is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  'Trivial chess' is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with 'Trivial chess'.  If not, see <http://www.gnu.org/licenses/>.
*/

/* SVN FILE: $Id$ */
/**
 * @author         $Author$
 * @version        $Rev$
 * @lastrevision   $Date$
 * @filesource     $URL$
 */

#ifndef CASTLINGAVAILABILITYCOM_H_
#define CASTLINGAVAILABILITYCOM_H_

#include <boost/cstdint.hpp>

#include "CastlingAvailabilityAbstract.h"

template<typename Int = int8_t>
class CastlingAvailabilityOrd
	: public CastlingAvailabilityAbstract<CastlingAvailabilityOrd<Int> > {
private:
	const static Int WHITE_QUEEN = 1;
	const static Int BLACK_QUEEN = 2;
	const static Int WHITE_KING  = 4;
	const static Int BLACK_KING  = 8;
public:
	CastlingAvailabilityOrd() {}

	bool whiteQueen() const { return this->availibility & WHITE_QUEEN; }
	bool blackQueen() const { return this->availibility & BLACK_QUEEN; }
	bool whiteKing() const  { return this->availibility & WHITE_KING; }
	bool blackKing() const  { return this->availibility & BLACK_KING; }

	void setWhiteQueen() { this->availibility |= WHITE_QUEEN; }
	void setBlackQueen() { this->availibility |= BLACK_QUEEN; }
	void setWhiteKing()  { this->availibility |= WHITE_KING; }
	void setBlackKing()  { this->availibility |= BLACK_KING; }

	void unsetWhiteQueen() { this->availibility &= ~WHITE_QUEEN; }
	void unsetBlackQueen() { this->availibility &= ~BLACK_QUEEN; }
	void unsetWhiteKing()  { this->availibility &= ~WHITE_KING; }
	void unsetBlackKing()  { this->availibility &= ~BLACK_KING; }

	bool operator==(const CastlingAvailabilityOrd<Int> ca) const {
		return ca.availibility == this->availibility;
	}
private:
	Int availibility;
};

#endif /* CASTLINGAVAILABILITYCOM_H_ */
